import java.util.ArrayList;

/**
 * Class <code>HeuristicI</code> 
 */
public class HeuristicI implements ISuspiciousnessCalculator {

	/**
	 *Calculate the Suspiciousness of each statement 
	 * @param nnStatementCoverTable  nnStatementCoverTable[i][j] is the number of test case i that execute statement j
	 * @return the Suspiciousness of each statement
	 */
	@Override
	public ArrayList<Double> calcSuspiciousness(
			ArrayList<ArrayList<Integer>> nnStatementCoverTable) {

		/**The Suspiciousness of each statement*/
		ArrayList<Double> darrSuspiciousness = 
			new ArrayList<Double>();
		
		for(int j = 0 ; j < nnStatementCoverTable.get(0).size()-1; j++ ){

			/**Number of failed tests that execute statement j*/
			double dTemp = 0;
			
			for(int i = 0 ; i <nnStatementCoverTable.size() ; i++ ){
				dTemp +=(double) (nnStatementCoverTable.get(i).get(j)>0 ? 1 : 0) 
				 * nnStatementCoverTable.get(i).get(nnStatementCoverTable.get(i).size()-1) ;
			}
			
			darrSuspiciousness.add(dTemp);
		}
		
		return darrSuspiciousness;
	}

}












